﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using FOModels.CarLoan;
using DataAccess.CarLoan;
using System.Net;
namespace Bussiness.CarLoan
{
    public class CarLoanBLL
    {
        private CarLoanDAL dal;
        public CarLoanBLL()
        {
            dal = new CarLoanDAL();
        }
        public List<CarLoanApplyModels> getcontractbycateid(int cateid)
        {
            List<CarLoanApplyModels> list = new List<CarLoanApplyModels>();
            CarLoanApplyModels fur;
            DataTable tb = dal.getcontractbycateid(cateid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new CarLoanApplyModels();
                    fur.CarLoanApplyID = int.Parse(row[0].ToString());
                    fur.CarLoanID = int.Parse(row[1].ToString());
                    fur.CustomerName = row[2].ToString();
                    fur.CustomerEmail = row[3].ToString();
                    fur.CustomerPhone = row[4].ToString();
                    fur.CustomerIncome = row[5].ToString();
                    fur.CustomerDOB = row[6].ToString();
                    fur.StatusID = int.Parse(row[7].ToString());
                    fur.AppDate = row[8].ToString();
                    fur.CarLoanName = row[10].ToString();
                    fur.StatusName = row[18].ToString();
                    fur.CompanyImg = row[20].ToString();
                    fur.CompanyName = row[27].ToString();
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<CarLoanApplyModels> getcontractbystatuscount(int cateid, int statusid)
        {
            List<CarLoanApplyModels> list = new List<CarLoanApplyModels>();
            CarLoanApplyModels fur;
            DataTable tb = dal.getcontractbystatuscount(cateid, statusid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new CarLoanApplyModels();
                    fur.CarLoanApplyID = int.Parse(row[0].ToString());
                    fur.CarLoanID = int.Parse(row[1].ToString());
                    fur.CustomerName = row[2].ToString();
                    fur.CustomerEmail = row[3].ToString();
                    fur.CustomerPhone = row[4].ToString();
                    fur.CustomerIncome = row[5].ToString();
                    fur.CustomerDOB = row[6].ToString();
                    fur.StatusID = int.Parse(row[7].ToString());
                    fur.AppDate = row[8].ToString();
                    fur.CarLoanName = row[10].ToString();
                    fur.StatusName = row[18].ToString();
                    fur.CompanyImg = row[20].ToString();
                    fur.CompanyName = row[27].ToString();
                    list.Add(fur);
                }
            }
            return list;
        }
        public CarLoanApplyModels getcontractbyid(int CarLoanapplyid)
        {

            CarLoanApplyModels fur = new CarLoanApplyModels();
            DataTable tb = dal.getcontractbyid(CarLoanapplyid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new CarLoanApplyModels();
                    fur.CarLoanApplyID = int.Parse(row[0].ToString());
                    fur.CarLoanID = int.Parse(row[1].ToString());
                    fur.CustomerName = row[2].ToString();
                    fur.CustomerEmail = row[3].ToString();
                    fur.CustomerPhone = row[4].ToString();
                    fur.CustomerIncome = row[5].ToString();
                    fur.CustomerDOB = row[6].ToString();
                    fur.StatusID = int.Parse(row[7].ToString());
                    fur.AppDate = row[8].ToString();
                    fur.CarLoanName = row[10].ToString();
                    fur.StatusName = row[18].ToString();
                    fur.CompanyImg = row[20].ToString();
                    fur.CompanyName = row[27].ToString();

                }
            }
            return fur;
        }
        public int CarLoanApply(int CarLoanID, CarLoanApplyModels CarLoan)
        {
            if (dal.CarLoanApply(CarLoanID, CarLoan) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteCarLoanApply(int CarLoanApplyID)
        {
            if (dal.DeleteCarLoanApply(CarLoanApplyID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int UpdateStatus(CarLoanApplyModels CarLoan)
        {
            if (dal.UpdateStatus(CarLoan) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public List<CarLoanModelscs> getCarLoanDefaultByProvider(int cateid, int CompanyID,int langid)
        {
            List<CarLoanModelscs> list = new List<CarLoanModelscs>();
            CarLoanModelscs fur;
            DataTable tb = dal.getCarLoanDefaultByProvider(cateid, CompanyID,langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new CarLoanModelscs();
                    fur.CarLoanID = int.Parse(row[0].ToString());
                    fur.CarLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.CarLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = String.Format("{0:0,0}", double.Parse(row[4].ToString())).Replace(',', '.');
                    fur.MaximumBalance = String.Format("{0:0,0}", double.Parse(row[5].ToString())).Replace(',', '.');
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                    fur.InterestVND = float.Parse(row[27].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<CarLoanModelscs> getCarLoanDefault(int cateid,int langid)
        {
            List<CarLoanModelscs> list = new List<CarLoanModelscs>();
            CarLoanModelscs fur;
            DataTable tb = dal.getCarLoanDefault(cateid,langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new CarLoanModelscs();
                    fur.CarLoanID = int.Parse(row[0].ToString());
                    fur.CarLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.CarLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = String.Format("{0:0,0}", double.Parse(row[4].ToString())).Replace(',', '.');
                    fur.MaximumBalance = String.Format("{0:0,0}", double.Parse(row[5].ToString())).Replace(',', '.');
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                    fur.InterestVND = float.Parse(row[27].ToString());
                    list.Add(fur);
                }
            }
            return list;
        } 
        public List<CarLoanModelscs> getCarLoan(int cateid, int planid, string balance, int years,int langid)
        {
            List<CarLoanModelscs> list = new List<CarLoanModelscs>();
            CarLoanModelscs fur;
            DataTable tb = dal.getCarLoan(cateid, planid, balance, years,langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new CarLoanModelscs();
                    fur.CarLoanID = int.Parse(row[0].ToString());
                    fur.CarLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.CarLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = String.Format("{0:0,0}", double.Parse(row[4].ToString())).Replace(',', '.');
                    fur.MaximumBalance = String.Format("{0:0,0}", double.Parse(row[5].ToString())).Replace(',', '.');
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                    fur.InterestVND = float.Parse(row[27].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<CarLoanModelscs> getCarLoanByProvider(int cateid, int planid, string balance, int years, int CompanyID,int langid)
        {
            List<CarLoanModelscs> list = new List<CarLoanModelscs>();
            CarLoanModelscs fur;
            DataTable tb = dal.getCarLoanByProvider(cateid, planid, balance, years, CompanyID,langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new CarLoanModelscs();
                    fur.CarLoanID = int.Parse(row[0].ToString());
                    fur.CarLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.CarLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = String.Format("{0:0,0}", double.Parse(row[4].ToString())).Replace(',', '.');
                    fur.MaximumBalance = String.Format("{0:0,0}", double.Parse(row[5].ToString())).Replace(',', '.');
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                    fur.InterestVND = float.Parse(row[27].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<CarLoanModelscs> getCarLoanMortgageDefaultByProvider(int cateid, int CompanyID, int langid)
        {
            List<CarLoanModelscs> list = new List<CarLoanModelscs>();
            CarLoanModelscs fur;
            DataTable tb = dal.getCarLoanMortgageDefaultByProvider(cateid, CompanyID, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new CarLoanModelscs();
                    fur.CarLoanID = int.Parse(row[0].ToString());
                    fur.CarLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.CarLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = String.Format("{0:0,0}", double.Parse(row[4].ToString())).Replace(',', '.');
                    fur.MaximumBalance = String.Format("{0:0,0}", double.Parse(row[5].ToString())).Replace(',', '.');
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                    fur.InterestVND = float.Parse(row[27].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<CarLoanModelscs> getCarLoanMortgageDefault(int cateid, int langid)
        {
            List<CarLoanModelscs> list = new List<CarLoanModelscs>();
            CarLoanModelscs fur;
            DataTable tb = dal.getCarLoanMortgageDefault(cateid, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new CarLoanModelscs();
                    fur.CarLoanID = int.Parse(row[0].ToString());
                    fur.CarLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.CarLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = String.Format("{0:0,0}", double.Parse(row[4].ToString())).Replace(',', '.');
                    fur.MaximumBalance = String.Format("{0:0,0}", double.Parse(row[5].ToString())).Replace(',', '.');
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                    fur.InterestVND = float.Parse(row[27].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<CarLoanModelscs> getCarLoanMortgage(int cateid, int planid, string balance, int years, int langid)
        {
            List<CarLoanModelscs> list = new List<CarLoanModelscs>();
            CarLoanModelscs fur;
            DataTable tb = dal.getCarLoanMortgage(cateid, planid, balance, years, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new CarLoanModelscs();
                    fur.CarLoanID = int.Parse(row[0].ToString());
                    fur.CarLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.CarLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = String.Format("{0:0,0}", double.Parse(row[4].ToString())).Replace(',', '.');
                    fur.MaximumBalance = String.Format("{0:0,0}", double.Parse(row[5].ToString())).Replace(',', '.');
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                    fur.InterestVND = float.Parse(row[27].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<CarLoanModelscs> getCarLoanMortgageByProvider(int cateid, int planid, string balance, int years, int CompanyID, int langid)
        {
            List<CarLoanModelscs> list = new List<CarLoanModelscs>();
            CarLoanModelscs fur;
            DataTable tb = dal.getCarLoanMortgageByProvider(cateid, planid, balance, years, CompanyID, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new CarLoanModelscs();
                    fur.CarLoanID = int.Parse(row[0].ToString());
                    fur.CarLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.CarLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = String.Format("{0:0,0}", double.Parse(row[4].ToString())).Replace(',', '.');
                    fur.MaximumBalance = String.Format("{0:0,0}", double.Parse(row[5].ToString())).Replace(',', '.');
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                    fur.InterestVND = float.Parse(row[27].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<CarLoanModelscs> getcarloantrustrelati(int cateid, int CompanyID, int CarLoanID,int langid)
        {
            List<CarLoanModelscs> list = new List<CarLoanModelscs>();
            CarLoanModelscs fur;
            DataTable tb = dal.getcarloantrustrelati(cateid, CompanyID, CarLoanID,langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new CarLoanModelscs();
                    fur.CarLoanID = int.Parse(row[0].ToString());
                    fur.CarLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.CarLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = String.Format("{0:0,0}", double.Parse(row[4].ToString())).Replace(',', '.');
                    fur.MaximumBalance = String.Format("{0:0,0}", double.Parse(row[5].ToString())).Replace(',', '.');
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                    list.Add(fur);
                }
            }
            return list;
        }
        public CarLoanModelscs getCarLoanByID(int CarLoanID, int langid)
        {
            CarLoanModelscs fur = new CarLoanModelscs();
            DataTable tb = dal.getCarLoanByID(CarLoanID, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.CarLoanID = int.Parse(row[0].ToString());
                    fur.CarLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.CarLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = String.Format("{0:0,0}", double.Parse(row[4].ToString())).Replace(',', '.');
                    fur.MaximumBalance = String.Format("{0:0,0}", double.Parse(row[5].ToString())).Replace(',', '.');
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public CarLoanModelscs getCarLoanByIDManager(int CarLoanID, int langid)
        {
            CarLoanModelscs fur = new CarLoanModelscs();
            DataTable tb = dal.getCarLoanByIDManager(CarLoanID, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.CarLoanID = int.Parse(row[0].ToString());
                    fur.CarLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.CarLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = String.Format("{0:0,0}", double.Parse(row[4].ToString())).Replace(',', '.');
                    fur.MaximumBalance = String.Format("{0:0,0}", double.Parse(row[5].ToString())).Replace(',', '.');
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public CarLoanModelscs getTOP1()
        {
            CarLoanModelscs fur = new CarLoanModelscs();
            DataTable tb = dal.getTOP1();
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.CarLoanID = int.Parse(row[0].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public List<CarLoanModelscs> getall(int cateid, int langid)
        {
            List<CarLoanModelscs> list = new List<CarLoanModelscs>();
            CarLoanModelscs fur;
            DataTable tb = dal.getall(cateid, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new CarLoanModelscs();
                    fur.CarLoanID = int.Parse(row[0].ToString());
                    fur.CarLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.CarLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = row[4].ToString();
                    fur.MaximumBalance = row[5].ToString();
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                    fur.FlagImage = row[28].ToString();
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<CarLoanCategoryModels> getallcarloancate(int langid)
        {
            List<CarLoanCategoryModels> list = new List<CarLoanCategoryModels>();
            CarLoanCategoryModels fur;
            DataTable tb = dal.getallcarloancate(langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new CarLoanCategoryModels();
                    fur.CarLoanCategoryID = int.Parse(row[0].ToString());
                    fur.CarLoanCategoryName = row[4].ToString();
                    list.Add(fur);
                }
            }
            return list;
        }
        public int UpdateCarLoan(CarLoanModelscs models, int langid)
        {
            if (dal.UpdateCarLoan(models) > 0 && dal.UpdateCarLoanLang(models, langid) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int InsertCarLoanTrust(CarLoanModelscs models)
        {
            if (dal.InsertCarLoanTrust(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int InsertCarLoanLang(CarLoanModelscs models, int langid)
        {
            if (dal.InsertCarLoanLang(models, langid) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int InsertCarLoanMortgage(CarLoanModelscs models)
        {
            if (dal.InsertCarLoanMortgage(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteCarLoan(int CarLoanID)
        {
            if (dal.DeleteCarLoanLang(CarLoanID) > 0 && dal.DeleteCarLoan(CarLoanID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
    }
}
